<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>boost/python/handle.hpp</title>
<link rel="stylesheet" href="../../boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../index.html" title="Boost.Python Reference Manual">
<link rel="up" href="../utility_and_infrastructure.html" title="Chapter 7. Utility and Infrastructure">
<link rel="prev" href="boost_python_pointee_hpp.html" title="boost/python/pointee.hpp">
<link rel="next" href="boost_python_type_id_hpp.html" title="boost/python/type_id.hpp">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../../images/boost.png"></td></tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="boost_python_pointee_hpp.html"><img src="../../images/prev.png" alt="Prev"></a><a accesskey="u" href="../utility_and_infrastructure.html"><img src="../../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="boost_python_type_id_hpp.html"><img src="../../images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="utility_and_infrastructure.boost_python_handle_hpp"></a><a class="link" href="boost_python_handle_hpp.html" title="boost/python/handle.hpp">boost/python/handle.hpp</a>
</h2></div></div></div>
<div class="toc"><dl class="toc">
<dt><span class="section"><a href="boost_python_handle_hpp.html#utility_and_infrastructure.boost_python_handle_hpp.introduction">Introduction</a></span></dt>
<dt><span class="section"><a href="boost_python_handle_hpp.html#utility_and_infrastructure.boost_python_handle_hpp.class_template_handle">Class
        template <code class="computeroutput"><span class="identifier">handle</span></code></a></span></dt>
<dt><span class="section"><a href="boost_python_handle_hpp.html#utility_and_infrastructure.boost_python_handle_hpp.function_borrowed">Function
        <code class="computeroutput"><span class="identifier">borrowed</span></code></a></span></dt>
<dt><span class="section"><a href="boost_python_handle_hpp.html#utility_and_infrastructure.boost_python_handle_hpp.function_allow_null">Function
        <code class="computeroutput"><span class="identifier">allow_null</span></code></a></span></dt>
</dl></div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="utility_and_infrastructure.boost_python_handle_hpp.introduction"></a><a class="link" href="boost_python_handle_hpp.html#utility_and_infrastructure.boost_python_handle_hpp.introduction" title="Introduction">Introduction</a>
</h3></div></div></div>
<p>
          &lt;boost/python/handle.hpp&gt; provides class template <code class="computeroutput"><span class="identifier">handle</span></code>,
          a smart pointer for managing reference-counted Python objects.
        </p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="utility_and_infrastructure.boost_python_handle_hpp.class_template_handle"></a><a class="link" href="boost_python_handle_hpp.html#utility_and_infrastructure.boost_python_handle_hpp.class_template_handle" title="Class template handle">Class
        template <code class="computeroutput"><span class="identifier">handle</span></code></a>
</h3></div></div></div>
<div class="toc"><dl class="toc">
<dt><span class="section"><a href="boost_python_handle_hpp.html#utility_and_infrastructure.boost_python_handle_hpp.class_template_handle.class_template_handle_constructo">Class
          template <code class="computeroutput"><span class="identifier">handle</span></code> constructors
          and destructor</a></span></dt>
<dt><span class="section"><a href="boost_python_handle_hpp.html#utility_and_infrastructure.boost_python_handle_hpp.class_template_handle.class_template_handle_modifiers">Class
          template <code class="computeroutput"><span class="identifier">handle</span></code> modifiers</a></span></dt>
<dt><span class="section"><a href="boost_python_handle_hpp.html#utility_and_infrastructure.boost_python_handle_hpp.class_template_handle.class_template_handle_observers">Class
          template <code class="computeroutput"><span class="identifier">handle</span></code> observers</a></span></dt>
</dl></div>
<p>
          <code class="computeroutput"><span class="identifier">handle</span></code> is a smart pointer
          to a Python object type; it holds a pointer of type <code class="computeroutput"><span class="identifier">T</span><span class="special">*</span></code>, where <code class="computeroutput"><span class="identifier">T</span></code>
          is its template parameter. T must be either a type derived from <code class="computeroutput"><span class="identifier">PyObject</span></code> or a <a class="link" href="../glossary.html#pod">POD</a>
          type whose initial <code class="computeroutput"><span class="keyword">sizeof</span><span class="special">(</span><span class="identifier">PyObject</span><span class="special">)</span></code> bytes are layout-compatible with <code class="computeroutput"><span class="identifier">PyObject</span></code>. Use <code class="computeroutput"><span class="identifier">handle</span><span class="special">&lt;&gt;</span></code> at the boundary between the Python/'C'
          API and high-level code; prefer object for a generalized interface to Python
          objects.
        </p>
<p>
          In this document, the term "upcast" refers to an operation which
          converts a pointer <code class="computeroutput"><span class="identifier">Y</span><span class="special">*</span></code>
          to a base class <code class="computeroutput"><span class="identifier">pointer</span> <span class="identifier">T</span><span class="special">*</span></code> via
          <code class="computeroutput"><span class="keyword">static_cast</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">*&gt;</span></code>
          if <code class="computeroutput"><span class="identifier">Y</span></code> is derived from <code class="computeroutput"><span class="identifier">T</span></code>, or via C-style cast (<code class="computeroutput"><span class="identifier">T</span><span class="special">*</span></code>) if
          it is not. However, in the latter case the "upcast" is ill-formed
          if the initial <code class="computeroutput"><span class="keyword">sizeof</span><span class="special">(</span><span class="identifier">PyObject</span><span class="special">)</span></code>
          bytes of <code class="computeroutput"><span class="identifier">Y</span></code> are not layout-compatible
          with <code class="computeroutput"><span class="identifier">PyObject</span></code>.
        </p>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">python</span>
<span class="special">{</span>
  <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
  <span class="keyword">class</span> <span class="identifier">handle</span>
  <span class="special">{</span>
      <span class="keyword">typedef</span> <span class="identifier">unspecified</span><span class="special">-</span><span class="identifier">member</span><span class="special">-</span><span class="identifier">function</span><span class="special">-</span><span class="identifier">pointer</span> <span class="identifier">bool_type</span><span class="special">;</span>

   <span class="keyword">public</span><span class="special">:</span> <span class="comment">// types</span>
      <span class="keyword">typedef</span> <span class="identifier">T</span> <span class="identifier">element_type</span><span class="special">;</span>

   <span class="keyword">public</span><span class="special">:</span> <span class="comment">// member functions</span>
      <span class="special">~</span><span class="identifier">handle</span><span class="special">();</span>

      <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Y</span><span class="special">&gt;</span>
      <span class="keyword">explicit</span> <span class="identifier">handle</span><span class="special">(</span><span class="identifier">detail</span><span class="special">::</span><span class="identifier">borrowed</span><span class="special">&lt;</span><span class="identifier">null_ok</span><span class="special">&lt;</span><span class="identifier">Y</span><span class="special">&gt;</span> <span class="special">&gt;*</span> <span class="identifier">p</span><span class="special">);</span>

      <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Y</span><span class="special">&gt;</span>
      <span class="keyword">explicit</span> <span class="identifier">handle</span><span class="special">(</span><span class="identifier">null_ok</span><span class="special">&lt;</span><span class="identifier">detail</span><span class="special">::</span><span class="identifier">borrowed</span><span class="special">&lt;</span><span class="identifier">Y</span><span class="special">&gt;</span> <span class="special">&gt;*</span> <span class="identifier">p</span><span class="special">);</span>

      <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Y</span><span class="special">&gt;</span>
      <span class="keyword">explicit</span> <span class="identifier">handle</span><span class="special">(</span><span class="identifier">detail</span><span class="special">::</span><span class="identifier">borrowed</span><span class="special">&lt;</span><span class="identifier">Y</span><span class="special">&gt;*</span> <span class="identifier">p</span><span class="special">);</span>

      <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Y</span><span class="special">&gt;</span>
      <span class="keyword">explicit</span> <span class="identifier">handle</span><span class="special">(</span><span class="identifier">null_ok</span><span class="special">&lt;</span><span class="identifier">Y</span><span class="special">&gt;*</span> <span class="identifier">p</span><span class="special">);</span>

      <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Y</span><span class="special">&gt;</span>
      <span class="keyword">explicit</span> <span class="identifier">handle</span><span class="special">(</span><span class="identifier">Y</span><span class="special">*</span> <span class="identifier">p</span><span class="special">);</span>

      <span class="identifier">handle</span><span class="special">();</span>

      <span class="identifier">handle</span><span class="special">&amp;</span> <span class="keyword">operator</span><span class="special">=(</span><span class="identifier">handle</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">r</span><span class="special">);</span>

      <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Y</span><span class="special">&gt;</span>
      <span class="identifier">handle</span><span class="special">&amp;</span> <span class="keyword">operator</span><span class="special">=(</span><span class="identifier">handle</span><span class="special">&lt;</span><span class="identifier">Y</span><span class="special">&gt;</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">r</span><span class="special">);</span> <span class="comment">// never throws</span>


      <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Y</span><span class="special">&gt;</span>
      <span class="identifier">handle</span><span class="special">(</span><span class="identifier">handle</span><span class="special">&lt;</span><span class="identifier">Y</span><span class="special">&gt;</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">r</span><span class="special">);</span>

      <span class="identifier">handle</span><span class="special">(</span><span class="identifier">handle</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">r</span><span class="special">);</span>

      <span class="identifier">T</span><span class="special">*</span> <span class="keyword">operator</span><span class="special">-&gt;</span> <span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
      <span class="identifier">T</span><span class="special">&amp;</span> <span class="keyword">operator</span><span class="special">*</span> <span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
      <span class="identifier">T</span><span class="special">*</span> <span class="identifier">get</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
      <span class="keyword">void</span> <span class="identifier">reset</span><span class="special">();</span>
      <span class="identifier">T</span><span class="special">*</span> <span class="identifier">release</span><span class="special">();</span>

      <span class="keyword">operator</span> <span class="identifier">bool_type</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> <span class="comment">// never throws</span>
   <span class="keyword">private</span><span class="special">:</span>
      <span class="identifier">T</span><span class="special">*</span> <span class="identifier">m_p</span><span class="special">;</span>
  <span class="special">};</span>

  <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span> <span class="keyword">struct</span> <span class="identifier">null_ok</span><span class="special">;</span>
  <span class="keyword">namespace</span> <span class="identifier">detail</span> <span class="special">{</span> <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span> <span class="keyword">struct</span> <span class="identifier">borrowed</span><span class="special">;</span> <span class="special">}</span>
<span class="special">}}</span>
</pre>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="utility_and_infrastructure.boost_python_handle_hpp.class_template_handle.class_template_handle_constructo"></a><a class="link" href="boost_python_handle_hpp.html#utility_and_infrastructure.boost_python_handle_hpp.class_template_handle.class_template_handle_constructo" title="Class template handle constructors and destructor">Class
          template <code class="computeroutput"><span class="identifier">handle</span></code> constructors
          and destructor</a>
</h4></div></div></div>
<pre class="programlisting"><span class="keyword">virtual</span> <span class="special">~</span><span class="identifier">handle</span><span class="special">();</span></pre>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Effects</span></dt>
<dd><p>
                  <code class="computeroutput"><span class="identifier">Py_XDECREF</span><span class="special">(</span><span class="identifier">upcast</span><span class="special">&lt;</span><span class="identifier">PyObject</span><span class="special">*&gt;(</span><span class="identifier">m_p</span><span class="special">))</span></code>
                </p></dd>
</dl>
</div>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Y</span><span class="special">&gt;</span>
<span class="keyword">explicit</span> <span class="identifier">handle</span><span class="special">(</span><span class="identifier">detail</span><span class="special">::</span><span class="identifier">borrowed</span><span class="special">&lt;</span><span class="identifier">null_ok</span><span class="special">&lt;</span><span class="identifier">Y</span><span class="special">&gt;</span> <span class="special">&gt;*</span> <span class="identifier">p</span><span class="special">);</span>
</pre>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Effects</span></dt>
<dd><pre class="programlisting"><span class="identifier">Py_XINCREF</span><span class="special">(</span><span class="identifier">upcast</span><span class="special">&lt;</span><span class="identifier">PyObject</span><span class="special">*&gt;(</span><span class="identifier">p</span><span class="special">));</span>
<span class="identifier">m_p</span> <span class="special">=</span> <span class="identifier">upcast</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">*&gt;(</span><span class="identifier">p</span><span class="special">);</span>
</pre></dd>
</dl>
</div>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Y</span><span class="special">&gt;</span>
<span class="keyword">explicit</span> <span class="identifier">handle</span><span class="special">(</span><span class="identifier">null_ok</span><span class="special">&lt;</span><span class="identifier">detail</span><span class="special">::</span><span class="identifier">borrowed</span><span class="special">&lt;</span><span class="identifier">Y</span><span class="special">&gt;</span> <span class="special">&gt;*</span> <span class="identifier">p</span><span class="special">);</span></pre>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Effects</span></dt>
<dd><pre class="programlisting"><span class="identifier">Py_XINCREF</span><span class="special">(</span><span class="identifier">upcast</span><span class="special">&lt;</span><span class="identifier">PyObject</span><span class="special">*&gt;(</span><span class="identifier">p</span><span class="special">));</span>
      <span class="identifier">m_p</span> <span class="special">=</span> <span class="identifier">upcast</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">*&gt;(</span><span class="identifier">p</span><span class="special">);</span>
</pre></dd>
</dl>
</div>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Y</span><span class="special">&gt;</span>
<span class="keyword">explicit</span> <span class="identifier">handle</span><span class="special">(</span><span class="identifier">detail</span><span class="special">::</span><span class="identifier">borrowed</span><span class="special">&lt;</span><span class="identifier">Y</span><span class="special">&gt;*</span> <span class="identifier">p</span><span class="special">);</span></pre>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Effects</span></dt>
<dd><pre class="programlisting"><span class="identifier">Py_XINCREF</span><span class="special">(</span><span class="identifier">upcast</span><span class="special">&lt;</span><span class="identifier">PyObject</span><span class="special">*&gt;(</span><span class="identifier">p</span><span class="special">));</span>
      <span class="identifier">m_p</span> <span class="special">=</span> <span class="identifier">upcast</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">*&gt;(</span><span class="identifier">expect_non_null</span><span class="special">(</span><span class="identifier">p</span><span class="special">));</span>
</pre></dd>
</dl>
</div>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Y</span><span class="special">&gt;</span>
<span class="keyword">explicit</span> <span class="identifier">handle</span><span class="special">(</span><span class="identifier">null_ok</span><span class="special">&lt;</span><span class="identifier">Y</span><span class="special">&gt;*</span> <span class="identifier">p</span><span class="special">);</span>
</pre>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Effects</span></dt>
<dd><p>
                  <code class="computeroutput"><span class="identifier">m_p</span> <span class="special">=</span>
                  <span class="identifier">upcast</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">*&gt;(</span><span class="identifier">p</span><span class="special">);</span></code>
                </p></dd>
</dl>
</div>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Y</span><span class="special">&gt;</span>
<span class="keyword">explicit</span> <span class="identifier">handle</span><span class="special">(</span><span class="identifier">Y</span><span class="special">*</span> <span class="identifier">p</span><span class="special">);</span>
</pre>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Effects</span></dt>
<dd><p>
                  <code class="computeroutput"><span class="identifier">m_p</span> <span class="special">=</span>
                  <span class="identifier">upcast</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">*&gt;(</span><span class="identifier">expect_non_null</span><span class="special">(</span><span class="identifier">p</span><span class="special">));</span></code>
                </p></dd>
</dl>
</div>
<pre class="programlisting"><span class="identifier">handle</span><span class="special">();</span>
</pre>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Effects</span></dt>
<dd><p>
                  <code class="computeroutput"><span class="identifier">m_p</span> <span class="special">=</span>
                  <span class="number">0</span><span class="special">;</span></code>
                </p></dd>
</dl>
</div>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Y</span><span class="special">&gt;</span>
<span class="identifier">handle</span><span class="special">(</span><span class="identifier">handle</span><span class="special">&lt;</span><span class="identifier">Y</span><span class="special">&gt;</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">r</span><span class="special">);</span>
<span class="identifier">handle</span><span class="special">(</span><span class="identifier">handle</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">r</span><span class="special">);</span>
</pre>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Effects</span></dt>
<dd><p>
                  m_p = r.m_p; Py_XINCREF(upcast&lt;PyObject*&gt;(m_p));
                </p></dd>
</dl>
</div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="utility_and_infrastructure.boost_python_handle_hpp.class_template_handle.class_template_handle_modifiers"></a><a class="link" href="boost_python_handle_hpp.html#utility_and_infrastructure.boost_python_handle_hpp.class_template_handle.class_template_handle_modifiers" title="Class template handle modifiers">Class
          template <code class="computeroutput"><span class="identifier">handle</span></code> modifiers</a>
</h4></div></div></div>
<pre class="programlisting"><span class="identifier">handle</span><span class="special">&amp;</span> <span class="keyword">operator</span><span class="special">=(</span><span class="identifier">handle</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">r</span><span class="special">);</span>
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Y</span><span class="special">&gt;</span>
<span class="identifier">handle</span><span class="special">&amp;</span> <span class="keyword">operator</span><span class="special">=(</span><span class="identifier">handle</span><span class="special">&lt;</span><span class="identifier">Y</span><span class="special">&gt;</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">r</span><span class="special">);</span> <span class="comment">// never throws</span>
</pre>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Effects</span></dt>
<dd><p>
                  <code class="computeroutput"><span class="identifier">Py_XINCREF</span><span class="special">(</span><span class="identifier">upcast</span><span class="special">&lt;</span><span class="identifier">PyObject</span><span class="special">*&gt;(</span><span class="identifier">r</span><span class="special">.</span><span class="identifier">m_p</span><span class="special">));</span>
                  <span class="identifier">Py_XDECREF</span><span class="special">(</span>
                  <span class="identifier">upcast</span><span class="special">&lt;</span><span class="identifier">PyObject</span><span class="special">*&gt;(</span><span class="identifier">m_p</span><span class="special">));</span>
                  <span class="identifier">m_p</span> <span class="special">=</span>
                  <span class="identifier">r</span><span class="special">.</span><span class="identifier">m_p</span><span class="special">;</span></code>
                </p></dd>
</dl>
</div>
<pre class="programlisting"><span class="identifier">T</span><span class="special">*</span> <span class="identifier">release</span><span class="special">();</span>
</pre>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Effects</span></dt>
<dd><p>
                  <code class="computeroutput"><span class="identifier">T</span><span class="special">*</span>
                  <span class="identifier">x</span> <span class="special">=</span>
                  <span class="identifier">m_p</span><span class="special">;</span>
                  <span class="identifier">m_p</span> <span class="special">=</span>
                  <span class="number">0</span><span class="special">;</span>
                  <span class="keyword">return</span> <span class="identifier">x</span><span class="special">;</span></code>
                </p></dd>
</dl>
</div>
<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">reset</span><span class="special">();</span>
</pre>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Effects</span></dt>
<dd><p>
                  <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span>
                  <span class="special">=</span> <span class="identifier">handle</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;();</span></code>
                </p></dd>
</dl>
</div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="utility_and_infrastructure.boost_python_handle_hpp.class_template_handle.class_template_handle_observers"></a><a class="link" href="boost_python_handle_hpp.html#utility_and_infrastructure.boost_python_handle_hpp.class_template_handle.class_template_handle_observers" title="Class template handle observers">Class
          template <code class="computeroutput"><span class="identifier">handle</span></code> observers</a>
</h4></div></div></div>
<pre class="programlisting"><span class="identifier">T</span><span class="special">*</span> <span class="keyword">operator</span><span class="special">-&gt;</span> <span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
<span class="identifier">T</span><span class="special">*</span> <span class="identifier">get</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
</pre>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Returns</span></dt>
<dd><p>
                  <code class="computeroutput"><span class="identifier">m_p</span><span class="special">;</span></code>
                </p></dd>
</dl>
</div>
<pre class="programlisting"><span class="identifier">T</span><span class="special">&amp;</span> <span class="keyword">operator</span><span class="special">*</span> <span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
</pre>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Returns</span></dt>
<dd><p>
                  <code class="computeroutput"><span class="special">*</span><span class="identifier">m_p</span><span class="special">;</span></code>
                </p></dd>
</dl>
</div>
<pre class="programlisting"><span class="keyword">operator</span> <span class="identifier">bool_type</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> <span class="comment">// never throws</span>
</pre>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Returns</span></dt>
<dd><p>
                  <code class="computeroutput"><span class="number">0</span></code> if <code class="computeroutput"><span class="identifier">m_p</span> <span class="special">==</span>
                  <span class="number">0</span></code>, a pointer convertible
                  to true otherwise.
                </p></dd>
</dl>
</div>
</div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="utility_and_infrastructure.boost_python_handle_hpp.function_borrowed"></a><a class="link" href="boost_python_handle_hpp.html#utility_and_infrastructure.boost_python_handle_hpp.function_borrowed" title="Function borrowed">Function
        <code class="computeroutput"><span class="identifier">borrowed</span></code></a>
</h3></div></div></div>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
<span class="identifier">detail</span><span class="special">::</span><span class="identifier">borrowed</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;*</span> <span class="identifier">borrowed</span><span class="special">(</span><span class="identifier">T</span><span class="special">*</span> <span class="identifier">p</span><span class="special">)</span>
<span class="special">{</span>
    <span class="keyword">return</span> <span class="special">(</span><span class="identifier">detail</span><span class="special">::</span><span class="identifier">borrowed</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;*)</span><span class="identifier">p</span><span class="special">;</span>
<span class="special">}</span>
</pre>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="utility_and_infrastructure.boost_python_handle_hpp.function_allow_null"></a><a class="link" href="boost_python_handle_hpp.html#utility_and_infrastructure.boost_python_handle_hpp.function_allow_null" title="Function allow_null">Function
        <code class="computeroutput"><span class="identifier">allow_null</span></code></a>
</h3></div></div></div>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
<span class="identifier">null_ok</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;*</span> <span class="identifier">allow_null</span><span class="special">(</span><span class="identifier">T</span><span class="special">*</span> <span class="identifier">p</span><span class="special">)</span>
<span class="special">{</span>
    <span class="keyword">return</span> <span class="special">(</span><span class="identifier">null_ok</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;*)</span><span class="identifier">p</span><span class="special">;</span>
<span class="special">}</span>
</pre>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2002-2005, 2015 David Abrahams, Stefan Seefeld<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="boost_python_pointee_hpp.html"><img src="../../images/prev.png" alt="Prev"></a><a accesskey="u" href="../utility_and_infrastructure.html"><img src="../../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="boost_python_type_id_hpp.html"><img src="../../images/next.png" alt="Next"></a>
</div>
</body>
</html>
